<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>FabGL: fabgl::SquareWaveGeneratorClass Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">FabGL
   </div>
   <div id="projectbrief">ESP32 VGA Controller and Graphics Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classfabgl_1_1_square_wave_generator_class.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classfabgl_1_1_square_wave_generator_class-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">fabgl::SquareWaveGeneratorClass Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>This is a square wave generator that uses APLL internal Audio PLL clock.  
 <a href="classfabgl_1_1_square_wave_generator_class.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="swgenerator_8h_source.html">swgenerator.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a445e3dc4197c4280e7331c5e302687e5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfabgl_1_1_square_wave_generator_class.html#a445e3dc4197c4280e7331c5e302687e5">begin</a> (bool div1_onGPIO0, gpio_num_t div2=GPIO_NUM_39, gpio_num_t div4=GPIO_NUM_39, gpio_num_t div8=GPIO_NUM_39, gpio_num_t div16=GPIO_NUM_39, gpio_num_t div32=GPIO_NUM_39, gpio_num_t div64=GPIO_NUM_39, gpio_num_t div128=GPIO_NUM_39, gpio_num_t div256=GPIO_NUM_39)</td></tr>
<tr class="memdesc:a445e3dc4197c4280e7331c5e302687e5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes <a class="el" href="classfabgl_1_1_square_wave_generator_class.html" title="This is a square wave generator that uses APLL internal Audio PLL clock. ">SquareWaveGeneratorClass</a> and associate GPIOs to the outputs.  <a href="#a445e3dc4197c4280e7331c5e302687e5">More...</a><br /></td></tr>
<tr class="separator:a445e3dc4197c4280e7331c5e302687e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4df2d6de4795d700d927c57f9f74f705"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfabgl_1_1_square_wave_generator_class.html#a4df2d6de4795d700d927c57f9f74f705">end</a> ()</td></tr>
<tr class="memdesc:a4df2d6de4795d700d927c57f9f74f705"><td class="mdescLeft">&#160;</td><td class="mdescRight">Disables all outputs.  <a href="#a4df2d6de4795d700d927c57f9f74f705">More...</a><br /></td></tr>
<tr class="separator:a4df2d6de4795d700d927c57f9f74f705"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad2e8c4f15d5784c631c7c04f90d9f91a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfabgl_1_1_square_wave_generator_class.html#ad2e8c4f15d5784c631c7c04f90d9f91a">play</a> (int freq, lldesc_t volatile *dmaBuffers=nullptr)</td></tr>
<tr class="memdesc:ad2e8c4f15d5784c631c7c04f90d9f91a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the main frequency.  <a href="#ad2e8c4f15d5784c631c7c04f90d9f91a">More...</a><br /></td></tr>
<tr class="separator:ad2e8c4f15d5784c631c7c04f90d9f91a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0e864e8d886cc044da13aec398fffc88"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classfabgl_1_1_square_wave_generator_class.html#a0e864e8d886cc044da13aec398fffc88">stop</a> ()</td></tr>
<tr class="memdesc:a0e864e8d886cc044da13aec398fffc88"><td class="mdescLeft">&#160;</td><td class="mdescRight">Disables all outputs.  <a href="#a0e864e8d886cc044da13aec398fffc88">More...</a><br /></td></tr>
<tr class="separator:a0e864e8d886cc044da13aec398fffc88"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This is a square wave generator that uses APLL internal Audio PLL clock. </p>
<p>When FABGLIB_USE_APLL_AB_COEF = 0 (the default) the frequency range is 2651514 Hz to 62500000 Hz.<br />
 Average error is 21 Hz, Minimum error is 0, Maximum error is 1000 Hz except for range 41666667 Hz to 42708333 Hz while frequency remains fixed at 41666666 Hz (error from 0 Hz to 1041666 Hz) and except for range 42708334 hz to 43748999 Hz while frequency remains fixed at 43750000 Hz (error from 750001 Hz to 1041666 Hz).</p>
<p>When FABGLIB_USE_APLL_AB_COEF = 1 the frequency range is 82500 Hz to 62500000 Hz. Unfortunately the output has lot of frequency jittering.<br />
 Average error is about 7 Hz, Minimum error is 0, Maximum error is 6349 Hz. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a445e3dc4197c4280e7331c5e302687e5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a445e3dc4197c4280e7331c5e302687e5">&#9670;&nbsp;</a></span>begin()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void fabgl::SquareWaveGeneratorClass::begin </td>
          <td>(</td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>div1_onGPIO0</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div2</em> = <code>GPIO_NUM_39</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div4</em> = <code>GPIO_NUM_39</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div8</em> = <code>GPIO_NUM_39</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div16</em> = <code>GPIO_NUM_39</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div32</em> = <code>GPIO_NUM_39</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div64</em> = <code>GPIO_NUM_39</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div128</em> = <code>GPIO_NUM_39</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">gpio_num_t&#160;</td>
          <td class="paramname"><em>div256</em> = <code>GPIO_NUM_39</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes <a class="el" href="classfabgl_1_1_square_wave_generator_class.html" title="This is a square wave generator that uses APLL internal Audio PLL clock. ">SquareWaveGeneratorClass</a> and associate GPIOs to the outputs. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">div1_onGPIO0</td><td>If true the undivided frequency is delivered on GPIO0. </td></tr>
    <tr><td class="paramname">div2</td><td>Specifies the GPIO where to send frequency / 2 (set GPIO_NUM_39 to disable output). </td></tr>
    <tr><td class="paramname">div4</td><td>Specifies the GPIO where to send frequency / 4 (set GPIO_NUM_39 to disable output). </td></tr>
    <tr><td class="paramname">div8</td><td>Specifies the GPIO where to send frequency / 8 (set GPIO_NUM_39 to disable output). </td></tr>
    <tr><td class="paramname">div16</td><td>Specifies the GPIO where to send frequency / 16 (set GPIO_NUM_39 to disable output). </td></tr>
    <tr><td class="paramname">div32</td><td>Specifies the GPIO where to send frequency / 32 (set GPIO_NUM_39 to disable output). </td></tr>
    <tr><td class="paramname">div64</td><td>Specifies the GPIO where to send frequency / 64 (set GPIO_NUM_39 to disable output). </td></tr>
    <tr><td class="paramname">div128</td><td>Specifies the GPIO where to send frequency / 128 (set GPIO_NUM_39 to disable output). </td></tr>
    <tr><td class="paramname">div256</td><td>Specifies the GPIO where to send frequency / 256 (set GPIO_NUM_39 to disable output).</td></tr>
  </table>
  </dd>
</dl>
<p>Example: </p><pre class="fragment">// Outputs 25Mhz on GPIO0 and 6.25Mhz on GPIO5, for 5 seconds
SquareWaveGenerator.begin(true, GPIO_NUM_39, GPIO_NUM_5);
SquareWaveGenerator.play(25000000);
delay(5000);
// Outputs 20Mhz on GPIO and 5Mhz on GPIO5, for 10 seconds
SquareWaveGenerator.play(20000000);
delay(10000);
SquareWaveGenerator.stop();</pre> 
</div>
</div>
<a id="a4df2d6de4795d700d927c57f9f74f705"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4df2d6de4795d700d927c57f9f74f705">&#9670;&nbsp;</a></span>end()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void fabgl::SquareWaveGeneratorClass::end </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Disables all outputs. </p>

</div>
</div>
<a id="ad2e8c4f15d5784c631c7c04f90d9f91a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad2e8c4f15d5784c631c7c04f90d9f91a">&#9670;&nbsp;</a></span>play()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void fabgl::SquareWaveGeneratorClass::play </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>freq</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">lldesc_t volatile *&#160;</td>
          <td class="paramname"><em>dmaBuffers</em> = <code>nullptr</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Sets the main frequency. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">freq</td><td>Frequency in Hertz. </td></tr>
    <tr><td class="paramname">dmaBuffers</td><td>Use only to provide custom DMA buffers.</td></tr>
  </table>
  </dd>
</dl>
<p>Example: </p><pre class="fragment">// Set 25MHz as main frequency
SquareWaveGenerator.play(25000000);</pre> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="_square_wave_generator_2_square_wave_generator_8ino-example.html#a1">SquareWaveGenerator/SquareWaveGenerator.ino</a>.</dd>
</dl>
</div>
</div>
<a id="a0e864e8d886cc044da13aec398fffc88"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0e864e8d886cc044da13aec398fffc88">&#9670;&nbsp;</a></span>stop()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void fabgl::SquareWaveGeneratorClass::stop </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Disables all outputs. </p>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="_square_wave_generator_2_square_wave_generator_8ino-example.html#a0">SquareWaveGenerator/SquareWaveGenerator.ino</a>.</dd>
</dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="swgenerator_8h_source.html">swgenerator.h</a></li>
<li>swgenerator.cpp</li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>fabgl</b></li><li class="navelem"><a class="el" href="classfabgl_1_1_square_wave_generator_class.html">SquareWaveGeneratorClass</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>
